<!DOCTYPE html>
<html>

<head lang="en">
    <title>骡窝日报</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/travel.css"/>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
    <script src="/js/plugins/dialog2/dialog.min.js"></script>

    <script>
        $(function () {


            var currentPage = 1;//当前页
            var pages;//总页数
            var travelData = [];//定义一个数组用来接收每次分页时的数据
            function query() {//记得传递当前页这个参数
                $.get("/news", {currentPage: currentPage, pageSize: 100}, function (data) {
                    $.merge(travelData, data.list);
                    var json = {
                        list: travelData
                    };

                    $(".news").renderValues(json, {
                        getHref: function (item, value) {
                            var url = $(item).data("href");
                            $(item).attr("href", url + value);
                        }
                    });
                    pages = data.pages;
                });
                currentPage++;
            };
            //默认查询第一页
            query();
            //监听滚动事件
            $(window).scroll(function () {
                if (($(document).scrollTop() + $(window).height()) >= $(document).height() - 1) {
                    if (currentPage <= pages) {
                        query();
                    } else {
                        $(document).dialog({
                            type: 'notice',
                            infoText: '已经到最底部了!',
                            autoClose: 2500,
                            position: 'bottom'  // center: 居中; bottom: 底部
                        });
                    }
                }
            });
        });
    </script>

</head>

<body>


<div class="search-head">
    <div class="row nav-search">
        <div class="col-1">
            <a href="javascript:history.go(-1);">
                <span><i class="fa fa-chevron-left fa-2x"></i></span>
            </a>
        </div>
        <div class="col-9">
            <div class="input-group-sm search">
                <input id="search" class="form-control" placeholder="搜索资讯">
            </div>
        </div>
        <div class="col-1">
            <i class="fa fa-search" id="searchBtn"
               style="color:white;font-size:25px;position: absolute;top: 23%;left: 88%">
            </i>
        </div>
    </div>
</div>

<div class="container news">
    <div class="news">
        <h6 class="news-title">骡窝日报 </h6>
        <div class="row" render-loop="list">
            <div class="col-6">
                <a data-href="newsContent.html?id=" render-key="list.id" render-fun="getHref">
                    <b render-html="list.title"></b>
                </a>
                <br/>
                <a data-href="newsContent.html?id=" render-key="list.id" render-fun="getHref">
                    <img class="rounded" width="100%" height="110px"
                         render-src="list.coverUrl">
                </a>
                <br>
                <div class="caption">
                    <span render-html="list.releseTime"> </span>
                    <br/>
                </div>
                <p></p>
            </div>
        </div>
    </div>
</div>


</body>
</html>